import os
import fileinput
import time

license

#version()
#failure=os.system('icl -IF:/vs2k5project/mlibrary/CSparse/Include -IF:/vs2k5project/CGAL-3.3.1/include -IF:/vs2k5project/boost/boost_1_36_0 -c main.cc')

def print_timing(func):
    def wrapper(*arg):
        t1 = time.time()
        res = func(*arg)
        t2 = time.time()
        print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
        return res
    return wrapper

@print_timing
def runqb(file):
    exefile = 'pcdqb.exe'
    mfile = file+'.m'
    pcdfile = 'pcd_'+file+'.txt'
    sympcdfile = 'pcd_qb_'+file+'_q.txt'
    symbfile = 'pcd_qb_'+file+'_b.txt'
    symvfile = 'pcd_qb_'+file+'_v.txt'
    symdfile = 'pcd_qb_'+file+'_d.txt'
    cmd = exefile + ' ' + mfile + ' ' + sympcdfile + ' ' + symbfile + ' ' + symvfile + ' ' + symdfile
    print(cmd)

    failure = os.system(cmd)

    if failure:
        print(mfile + ' failed\n');
    else:
        print(mfile + ' succeeded\n');




files=['irrabbit' ]





for file in files:
    runqb(file)


#gnuplot = os.popen('gnuplot -persist', 'w')
#gnuplot.write("""
#set xrange [0:10]; set yrange [-2:2]
#plot sin(x)
#quit
#""")
#gnuplot.close() # gnuplot is now run with the written input


